package com.tao.design.strategy.demo2;

/**
 * @Author Mi_Tao
 * @Date 2023/4/14
 * @Description 有状态模式，每次都会根据不同的类型来创建一个支付方式
 * @Version 1.0
 **/
public class PaymentFactory2 {
    public static Payment getPayment(PaymentEnum payType) {
        if (payType == null) {
            throw new IllegalArgumentException("pay type is empty.");
        }
        if (payType == PaymentEnum.Weixin) {
            return new WxPayment();
        }
        if (payType == PaymentEnum.Ali) {
            return new AlipayPayment();
        }
        if (payType == PaymentEnum.Bank_Card) {
            return new BankCardPayment();
        }
        throw new IllegalArgumentException("pay type not supported.");
    }
}
